package com.artqiyi.dollmachine.views.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.widget.ImageView;
import android.widget.TextView;

import com.artqiyi.dollmachine.R;
import com.artqiyi.dollmachine.common.constant.Constant;
import com.artqiyi.dollmachine.model.entity.GameRecordBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/10/30 0030.
 */

public class MineCatchRecordAdapter extends BaseQuickAdapter<GameRecordBean, BaseViewHolder>{

    public MineCatchRecordAdapter(@Nullable List<GameRecordBean> data) {
        super(R.layout.item_mine_catch_record, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GameRecordBean item) {
        helper.setText(R.id.tvName, item.getWare_name());
        helper.setText(R.id.tvTime, item.getCreated_at());
        setGameCatchResult(helper.getView(R.id.tvResult), item.getOperate_result());
        Glide.with(mContext).load(item.getWare_image()).into((ImageView) helper.getView(R.id.imageDoll));
    }

    private void setGameCatchResult(TextView tvResult, int result) {
        if (result == Constant.OPERATE_RESULT_SUCCESS) {
            tvResult.setText("抓取成功");
            tvResult.setTextColor(ContextCompat.getColor(mContext, R.color.cEC6564));
        } else if (result == Constant.OPERATE_RESULT_FAIL) {
            tvResult.setText("抓取失败");
            tvResult.setTextColor(ContextCompat.getColor(mContext, R.color.c93979B));
        } else {
            tvResult.setText("抓取失败");
            tvResult.setTextColor(ContextCompat.getColor(mContext, R.color.c93979B));
        }
    }
}
